/*
 * @Author: your name
 * @Date: 2021-05-24 14:20:37
 * @LastEditTime: 2021-05-31 22:04:32
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \遵义报名\zunyi\src\router\index.js
 */

import Vue from "vue"
import VueRouter from "vue-router"
import { routes } from "./commonRoutes.js"
Vue.use(VueRouter)
let router = new VueRouter({
    routes,
    mode: 'history'
})


//全局前置路由拦截
router.beforeEach((to, from, next) => {
    if(to.meta.interceptors){
        next()
    }else{
        if(!localStorage.getItem("zunyi_pc_token")){//没有token
            next({path:'/'})//回登录页
        }else{//有token
            next()
        }
    }
})

export default router